//
//  MLAShopFoodBottomView.m
//  MagicLampApp
//
//  Created by Zheng on 2019/4/4.
//  Copyright © 2019 zheng.magic.lamp.app. All rights reserved.
//

#import "MLAShopFoodBottomView.h"

@implementation MLAShopFoodBottomView

- (instancetype)init {
    self = [super init];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = CX_GetColorHex(0xEBEBEB, 1);
        [self addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.offset(0);
            make.height.offset(1);
        }];
        
        _cartBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _cartBtn.frame = CGRectMake(0,0,58,58);
        [_cartBtn setImage:[UIImage imageNamed:@"f_shop_cart"] forState:UIControlStateNormal];
        _cartBtn.layer.shadowOffset = CGSizeMake(0,1);
        _cartBtn.layer.shadowOpacity = 1;
        _cartBtn.layer.shadowRadius = 7;
        _cartBtn.layer.shadowColor = CX_GetColorHex(0x5C9EEB, 1).CGColor;
        _cartBtn.backgroundColor = [UIColor whiteColor];
        _cartBtn.layer.cornerRadius = 29;
        [self addSubview:_cartBtn];
        [_cartBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(15);
            make.bottom.offset(-10);
            make.width.height.offset(58);
        }];
        
        _numLbl = [[UILabel alloc] init];
        _numLbl.textAlignment = NSTextAlignmentCenter;
        _numLbl.textColor = [UIColor whiteColor];
        _numLbl.backgroundColor = CX_GetColorRed();
        _numLbl.layer.cornerRadius = 9;
        _numLbl.layer.masksToBounds = YES;
        _numLbl.font = CX_GetNormalFont(11);
        [_cartBtn addSubview:_numLbl];
        [_numLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.mas_greaterThanOrEqualTo(18);
            make.top.offset(1);
            make.right.offset(-1);
        }];
        
        _buyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _buyBtn.backgroundColor = CX_GetColorHex(0x0094F2, 1);
        _buyBtn.titleLabel.font = CX_GetNormalFont(14);
        _buyBtn.layer.cornerRadius = 5;
        _buyBtn.layer.masksToBounds = YES;
        [_buyBtn setTitle:@"去结算" forState:UIControlStateNormal];
        [self addSubview:_buyBtn];
        [_buyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.offset(100);
            make.height.offset(40);
            make.right.offset(-15);
            make.bottom.offset(-10);
        }];
        
        
        _titleLbl = [[UILabel alloc] init];
        _titleLbl.font = CX_GetNormalFont(16);
        _titleLbl.text = @"合计：";
        [self addSubview:_titleLbl];
        [_titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(92);
            make.centerY.offset(0);
            make.width.offset(50);
        }];
        
        _priceLbl = [[UILabel alloc] init];
        _priceLbl.textColor = CX_GetColorRed();
        _priceLbl.font = CX_GetNormalFont(14);
        _priceLbl.text = @"0.00";
        [self addSubview:_priceLbl];
        [_priceLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.titleLbl.mas_right);
            make.centerY.offset(0);
            make.right.equalTo(self.buyBtn.mas_left).offset(-15);
        }];

    }
    return self;
}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    UIView *view = [super hitTest:point withEvent:event];
    CGPoint tempPoint = [_cartBtn convertPoint:point fromView:self];
    if ([_cartBtn pointInside:tempPoint withEvent:event]) {
        return _cartBtn;
    }
    return view;
}

@end
